/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.manager;

import br.com.deployment.message.Msg;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.primefaces.event.map.MarkerDragEvent;
import org.primefaces.event.map.OverlaySelectEvent;
import org.primefaces.model.map.DefaultMapModel;
import org.primefaces.model.map.LatLng;
import org.primefaces.model.map.MapModel;
import org.primefaces.model.map.Marker;

/**
 *
 * @author roniere
 */
@ManagedBean
@ViewScoped
public class ManagerGmap implements Serializable{
    private MapModel simpleModel;
    private Marker marker;

    public ManagerGmap() {
    }
    
    @PostConstruct
    public void init(){
        simpleModel = new DefaultMapModel(); 
        
        LatLng coord1 = new LatLng(-2.92867970, -41.75083009999999); 
        simpleModel.addOverlay(new Marker(coord1, "Teste"));
        
         for(Marker marker : simpleModel.getMarkers()) {  
            marker.setDraggable(true);  
        }  
    }

    public MapModel getSimpleModel() {
        return simpleModel;
    }

    public void setSimpleModel(MapModel simpleModel) {
        this.simpleModel = simpleModel;
    }

    public Marker getMarker() {
        return marker;
    }

    public void setMarker(Marker marker) {
        this.marker = marker;
    }
    
    public void onMarkerSelect(OverlaySelectEvent event) {
        this.marker = (Marker) event.getOverlay();
   }
    public void onMarkerDrag(MarkerDragEvent event) {  
        this.marker = event.getMarker();  
        Msg msg = new Msg();
        msg.messagemInfo("Coord "+marker.getLatlng());
    }  
    
    
}
